local skel = fk.CreateSkill {
  name = "efengqi__jushou",
}

Fk:loadTranslationTable{
  ["efengqi__jushou"] = "据守",
  [":efengqi__jushou"] = "出牌阶段结束时，或你受到伤害后，你可以移动场上一张牌，然后翻面并结束当前回合。",
  ["#efengqi__jushou-move"] = "据守：你可选择两名角色，在两人之间移动场上一张牌，翻面并结束回合",

  ["$efengqi__jushou1"] = "坚守勿出，严阵以待。",
  ["$efengqi__jushou2"] = "以静制动，以逸待劳。",
}

local spec = {
  on_cost = function (self, event, target, player, data)
    local tos = player.room:askToChooseToMoveCardInBoard(player, { prompt = "#efengqi__jushou-move", skill_name = skel.name })
    if #tos > 0 then
      event:setCostData(self, { tos = tos })
      return true
    end
  end,
  on_use = function (self, event, target, player, data)
    local room = player.room
    local tar1, tar2 = table.unpack(event:getCostData(self).tos)
    room:askToMoveCardInBoard(player, { target_one = tar1, target_two = tar2, skill_name = skel.name})
    if player:isAlive() then
      player:turnOver()
    end
    room:endTurn()
  end,
}

skel:addEffect(fk.EventPhaseEnd, {
  anim_type = "defensive",
  can_trigger = function(self, event, target, player, data)
    if target == player and player:hasSkill(skel.name) then
      return player.phase == Player.Play and #player.room:canMoveCardInBoard() > 0
    end
  end,
  on_cost = spec.on_cost,
  on_use = spec.on_use,
})

skel:addEffect(fk.Damaged, {
  anim_type = "defensive",
  can_trigger = function(self, event, target, player, data)
    if target == player and player:hasSkill(skel.name) then
      return #player.room:canMoveCardInBoard() > 0
    end
  end,
  on_cost = spec.on_cost,
  on_use = spec.on_use,
})

return skel
